home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_3.5 / Examples / Reaction / ralib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-30  |  3.0 KB  |  110 lines

  1. /*
  2. *
  3. * COPYRIGHT:
  4. *
  5. *   Unless otherwise noted, all files are Copyright (c) 1999 Amiga, Inc.
  6. *   All rights reserved.
  7. *
  8. * DISCLAIMER:
  9. *
  10. *   This software is provided "as is". No representations or warranties
  11. *   are made with respect to the accuracy, reliability, performance,
  12. *   currentness, or operation of this software, and all use is at your
  13. *   own risk. Neither Amiga nor the authors assume any responsibility
  14. *   or liability whatsoever with respect to your use of this software.
  15. *
  16.  
  17.  
  18.    After SetGadgetAttrsA() a BOOPSI gadget returns 0 if it does not need
  19.    refreshing and returns a value != 0 if it needs refreshing.
  20.  
  21.    But GADGETCLASS breaks this rule: It always returns 0. But especially
  22.    after setting GA_Disabled the gadget needs refreshing most time.
  23.  
  24.    The following 4 function encapsulate this:
  25.  
  26.    1. RefreshSetGadgetAttrsA() set the gadget attributes and refreshs the
  27.       gadget if it says so or if the disable flag changed.
  28.  
  29.    2. RefreshSetGadgetAttrs() is a tag stub function
  30.       for RefreshSetGadgetAttrsA().
  31.  
  32.    3. RefreshSetPageGadgetAttrsA() is like RefreshSetGadgetAttrsA() but needs
  33.       the parent page object also. It must be used if the gadget is part of
  34.       a page object and may or may not be visible.
  35.  
  36.    4. RefreshSetPageGadgetAttrs() is a tag stub function
  37.       for RefreshSetPageGadgetAttrsA().
  38.  
  39.     Note: If a gadget does handle GA_Disabled itself and does refresh itself
  40.           it is refreshed a second time using this function. In that case you
  41.           should not use these function but SetGadgetAttrsA() and
  42.           SetPageGadgetAttrsA().
  43.  
  44. */
  45.  
  46. #include <intuition/gadgetclass.h>
  47.  
  48. #include <clib/utility_protos.h>
  49. #include <clib/intuition_protos.h>
  50. #include <clib/layout_protos.h>
  51.  
  52. ULONG
  53. RefreshSetGadgetAttrsA(struct Gadget *g, struct Window *w, struct Requester *r, struct TagItem *tags)
  54. {
  55.     ULONG retval;
  56.     BOOL changedisabled = FALSE;
  57.     BOOL disabled;
  58.  
  59.     if (w)
  60.     {
  61.         if (FindTagItem(GA_Disabled,tags))
  62.         {
  63.             changedisabled = TRUE;
  64.              disabled = g->Flags & GFLG_DISABLED;
  65.          }
  66.      }
  67.     retval = SetGadgetAttrsA(g,w,r,tags);
  68.     if (w && (retval || (changedisabled && disabled != (g->Flags & GFLG_DISABLED))))
  69.     {
  70.         RefreshGList(g,w,r,1);
  71.         retval = 1;
  72.     }
  73.     return retval;
  74. }
  75.  
  76. ULONG
  77. RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1, ...)
  78. {
  79.     return RefreshSetGadgetAttrsA(g,w,r,(struct TagItem *) &tag1);
  80. }
  81.  
  82. ULONG
  83. RefreshSetPageGadgetAttrsA(struct Gadget *g, Object *p, struct Window *w, struct Requester *r, struct TagItem *tags)
  84. {
  85.     ULONG retval;
  86.     BOOL changedisabled = FALSE;
  87.     BOOL disabled;
  88.     if (w)
  89.     {
  90.         if (FindTagItem(GA_Disabled,tags))
  91.         {
  92.             changedisabled = TRUE;
  93.              disabled = g->Flags & GFLG_DISABLED;
  94.          }
  95.      }
  96.     retval = SetPageGadgetAttrsA(g,p,w,r,tags);
  97.     if (w && (retval || (changedisabled && disabled != (g->Flags & GFLG_DISABLED))))
  98.     {
  99.         RefreshPageGadget(g,p,w,r);
  100.         retval = 1;
  101.     }
  102.     return retval;
  103. }
  104.  
  105. ULONG
  106. RefreshSetPageGadgetAttrs(struct Gadget *g, Object *p, struct Window *w, struct Requester *r, Tag tag1, ...)
  107. {
  108.     return RefreshSetPageGadgetAttrsA(g,p,w,r,(struct TagItem *) &tag1);
  109. }
  110.